﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LaunchPad.Core.Controls.Tracks
{
    public class WorkProgressCallback
    {
        public WorkProgressCallback(Action<double> percentCompleteCallback)
        {
            PercentCompleteCallback = percentCompleteCallback;
        }

        public Action<double> PercentCompleteCallback { get; set; }

        public int TotalWork { get; set; }
        public int CompletedWork { get; private set; }

        public void WorkUnitComplete()
        {
            WorkComplete(1);
        }

        public void WorkComplete(int amount)
        {
            CompletedWork += amount;
            OnWorkUpdate();
        }

        protected void OnWorkUpdate()
        {
            PercentCompleteCallback.Invoke((double)CompletedWork * 100 / TotalWork);
        }
    }
}
